Skip to main content

Using .id with XPath

Using .id with XPath

Depending on what you want to do, the sentence .id after an XPath might be required or not.

When adding elements to a collection

Imagine a Personal Loan Request process, where there are several products for each request. There is a one-to-many relationship between the Process Entity Request and the collection entity Products.

• The one is called Request.
• The collection entity is called Products.
• The relationship is Request_Products
• Products has an attribute called Value

You need to add a new product to the collection with US$1000 in value, use the following statements:

DO ADD

var NewProduct = Me.newCollectionItem(“idRequest.Request_Products”);
NewProduct.setXPath(“Value”, 1000);

DO NOT ADD

NewProduct.setXPath(“idRequest”,(idRequest.id));

This last statement damages the relationship because the newCollectionItem function fills the id of the attribute automatically.

When using setXPath with direct setting

When you use the setXPath statement set the object, not the integer of the relationship.

Using the image below, imagine that you have a Help Desk process that handles reports of incidents (or Tickets) in order to minimize disruptions in Information Technology Services.

According to how the ticket evolves in the process it will change its Status. There is an entity-related relationship between the Process Entity called Ticket and the parameter entity called Status. The values are shown below.

BusinessRulesElements8

We use an assignment element to set the status of the Ticket.
As the ticket is received by the Help Desk department, its status will be set to Open.

DO ADD

var parameters = new FilterParameters();
parameters.AddParameter("@Code", 1);
var Status = CHelper.getEntityAttrib("HelpDeskCaseStatus","idStatus","Code = @Code",parameters);
<Ticket.Status> = Status;

DO NOT ADD:

var parameters = new FilterParameters();
parameters.AddParameter("@Code", 1);
var Status = CHelper.getEntityAttrib("HelpDeskCaseStatus","idStatus","Code = @Code",parameters);
<Ticket.Status.id> = Status;

DO NOT ADD:

var parameters = new FilterParameters();
parameters.AddParameter("@Code", 1);
var Status = CHelper.getEntityAttrib("HelpDeskCaseStatus","idStatus","Code = @Code",parameters);
<Ticket.Status> = Status.id;

When using setXPath in the newCollectionItem function

When using the newCollectionItem function you need to set the Xpaths of the attributes of the new record of the collection.

There is a special case where you need to use the .id: When the setXPath sentence includes a getXPath sentence to set a value.

Imagine you have Purchase Request process that can include many customers. Thus, there is a one-to-many relationship between the Process Entity PurchaseRequest and Customers. There is also a related attribute relationship between PurchaseRequest and Customers, that stores the main customer of the request.

You need to add to the Customers collection the name of the main customer and its status.

• The Process Entity is called ProductsRequest.
• The collection entity is called Customers.
• The related entity relationship is MainCustomer
• The relationship is ProductRequest_Customers
• Customers has an attribute called Name

var AddCustomer=Me.newCollectionItem("ProductsRequest.ProductRequest_Customers");
AddCustomer.setXPath("CustomerName",Me.getXPath("MainCustomer.Name"));
AddCustomer.setXPath("Status",Me.getXPath("MainCustomer.Status.id"));

When using getXPath with a filtered collection

When you use the getXPath in collections, and need a filter to a table with a variable, you need the .id.

Imagine you have a Collective Policy Underwriting where there are several vehicles for each request. You need to know how many vehicles of a certain type there are in the request.

There is a one-to-many relationship between the Process Entity Request and the collection entity Vehicles.

• The one is called Request.
• The collection entity is called Vehicles.
• The relationship is Request_Vehicles
• Products has an attribute called VehicleType that is related to a parameter entity.

DO ADD

var parameters = new FilterParameters();
parameters.AddParameter("@Code", 1);
var idVehicleType = CHelper.getEntityAttrib("VehicleType","idType","Code = @Code",parameters);
var CountVehicles = Me.getXPath("count(Request.Request_Vehicles["VehicleType.id = "+idVehicleType+"])");

DO NOT ADD

var parameters = new FilterParameters();
parameters.AddParameter("@Code", 1);
var idVehicleType = CHelper.getEntityAttrib("VehicleType","idType","Code = @Code",parameters);
var CountVehicles = Me.getXPath("count(Request.Request_Vehicles["VehicleType.id = "+idVehicleType.id+"])");

When comparing Xpaths in if sentences

When you compare Xpaths in if sentences, compare to the entity object without using the .id.

  1. DO ADD
if (!IsNull(Request.getXPath("VehicleType")))

**DO NOT ADD**

if (Request.getXPath("VehicleType.id") != null)
  1. DO ADD
if(idVehicleType == Request.getXPath("VehicleType"))
If idVehicleType is a variable that relates to an entity

DO NOT ADD

if(idVehicleType == Request.getXPath("VehicleType.id"))
If idVehicleType is a variable that relates to an entity
  1. DO ADD
if (Request.getXPath("VehicleType.Code") == 2)

DO NOT ADD

var parameters = new FilterParameters();
parameters.AddParameter("@Code", 2);
var idVehicleType = CHelper.getEntityAttrib("VehicleType","idType","Code = @Code",parameters);
if (Request.getXPath("VehicleType.id")==idVehicleType)